import { getPlaiceholder } from 'plaiceholder'

export async function useImagePlaceholder(source: any) {
  const buffer = await fetch(source).then(async (res) => {
    return Buffer.from(await res.arrayBuffer())
  })

  const { base64 } = await getPlaiceholder(buffer)

  return { base64 }
}
